<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>工作室管理 - 运输管理 - 新增运费模板</title>
    <link rel="stylesheet" type="text/css" href="/static/style/common.css">
    <link rel="stylesheet" type="text/css" href="/static/style/newfreighttemp.css">
</head>

<body>
<!-- 运输管理通用头部 -->
<jsp:include page="../common/settingheader.jsp" flush="true"></jsp:include>
<!-- 运输管理通用头部 end -->

<!-- 运费模板 -->
<div class="wrapper">
    <jsp:include page="../common/settingmenu.jsp" flush="true"></jsp:include>
    <div class="shopmanagerightcontent">
        <div class="shopmanageright">
            <div class="newtemptitle">
                <h1>物流运费管理</h1>
            </div>
            <div class="tempname">
                <h1>模板名称：</h1>
                <div class="newinputtype">
                    <input type="text" value="${temp.name}" class="nametext" /><i>╲</i>
                    <input type="hidden" id="tempId" value="${temp.id}"/>
                </div>
            </div>
            <div class="tempname">
                <h1>是否包邮：</h1>
                <ul class="settemptype">
                    <li><i <c:if test="${!temp.isFree}">class="selected"</c:if>></i><label>自定义运费</label></li>
                    <li><i <c:if test="${temp.isFree}">class="selected"</c:if>></i><label>卖家承担运费</label></li>
                </ul>
            </div>
            <%--
            <div class="tempname">
                <h1>计费方式：</h1>
                <ul class="settemppricetype">
                    <li><i class="selected"></i><label>按件数</label></li>
                    <li><i></i><label>按重量</label></li>
                    <li><i></i><label>按体积</label></li>
                </ul>
            </div>
            --%>
            <div class="tempname">
                <h1>运送方式：</h1>
                <dl class="settempwaytype">
                    <dt>除指定地区外，其余地区的运费采用“默认运费”</dt>
                    <c:forEach items="${deliveryMethods}" var="method">
                        <c:forEach items="${temp.freightTempSubs}" var="sub">
                            <c:if test="${sub.deliveryMethod.id == method.id}">
                                <c:set var="_sub" value="${sub}"></c:set>
                            </c:if>
                        </c:forEach>
                    <dd>
                        <div class="selectway"><i mid="${method.id}" <c:if test="${_sub.deliveryMethod.id == method.id}">class="selected"</c:if> ></i><label>${method.name}</label></div>
                        <div class="editfreightpricebox">
                            <div class="defaultsetup">
                                <div class="defaultitem w1">
                                    <span>默认运费</span>
                                    <div class="newinputtype"><input type="text" <c:if test="${_sub.deliveryMethod.id == method.id}">value="${_sub.inRange}"</c:if> class="nametext" setnum="num" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)" /><i>╲</i></div>
                                    <span class="unit">件内</span>
                                </div>
                                <div class="defaultitem w2">
                                    <div class="newinputtype"><input type="text" <c:if test="${_sub.deliveryMethod.id == method.id}">value="<fmt:formatNumber value="${_sub.inRangePrice/100}" pattern="0.00"/>"</c:if> class="nametext" setnum="price" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)" /><i>╲</i></div>
                                    <span class="unit">元</span>
                                </div>
                                <div class="defaultitem w3">
                                    <span>每增加</span>
                                    <div class="newinputtype"><input type="text" <c:if test="${_sub.deliveryMethod.id == method.id}">value="${_sub.outRangeWeight}"</c:if> class="nametext" setnum="num" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)" /><i>╲</i></div>
                                    <span class="unit">件</span>
                                </div>
                                <div class="defaultitem w4">
                                    <span>增加运费</span>
                                    <div class="newinputtype"><input type="text" <c:if test="${_sub.deliveryMethod.id == method.id}">value="<fmt:formatNumber value="${_sub.outRangePrice/100}" pattern="0.00"/>"</c:if> class="nametext" setnum="price" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)" /><i>╲</i></div>
                                    <span class="unit">元</span>
                                </div>
                            </div>
                            <div class="newtemp">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tbody>
                                    <tr>
                                        <td width="34%">运送到</td>
                                        <td width="14%">首件（件）</td>
                                        <td width="14%">首费（元）</td>
                                        <td width="14%">续件（件）</td>
                                        <td width="14%">续费（元）</td>
                                        <td width="10%">操作</td>
                                    </tr>
                                    <c:if test="${_sub.deliveryMethod.id == method.id}">
                                        <c:forEach items="${_sub.destinations}" var="des">
                                            <tr>
                                                <td>
                                                    <table width="98%" border="0" cellspacing="0" cellpadding="0"
                                                           class="freightleft">
                                                        <tbody>
                                                        <tr class="editareabox">
                                                            <c:set var="areaIds" value=""></c:set>
                                                            <c:set var="areaNames" value=""></c:set>
                                                            <c:forEach items="${des.areas}" var="area" varStatus="st">
                                                                <c:set var="areaIds" value="${areaIds}${area.areaId}"></c:set>
                                                                <c:set var="areaNames" value="${areaNames}${area.areaName}"></c:set>
                                                                <c:if test="${!st.last}">
                                                                    <c:set var="areaIds" value="${areaIds},"></c:set>
                                                                    <c:set var="areaNames" value="${areaNames}/"></c:set>
                                                                </c:if>
                                                            </c:forEach>
                                                            <td class="areaname" width="66%" areaIds="${areaIds}">${areaNames}</td>
                                                            <td class="editarea" width="34%"><a href="javascript:;">编辑</a></td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </td>
                                                <td><input type="text" setnum="num" value="${des.inRange}" onkeyup="clearNoNum(event,this)"
                                                           onblur="checkNum(this)"></td>
                                                <td><input type="text" setnum="price" value="<fmt:formatNumber value="${des.inRangePrice/100}" pattern="0.00"/>"
                                                           onkeyup="clearNoNum(event,this)" onblur="checkNum(this)"></td>
                                                <td><input type="text" setnum="num" value="${des.outRangeWeight}" onkeyup="clearNoNum(event,this)"
                                                           onblur="checkNum(this)"></td>
                                                <td><input type="text" setnum="price" value="<fmt:formatNumber value="${des.outRangePrice/100}" pattern="0.00"/>"
                                                           onkeyup="clearNoNum(event,this)" onblur="checkNum(this)"></td>
                                                <td><a href="javascript:;" class="delcurarea">删除</a></td>
                                            </tr>
                                        </c:forEach>
                                    </c:if>
                                    </tbody>
                                </table>
                            </div>
                            <div class="addnewtemp">
                                <h1>为指定地区城市设置运费</h1>
                            </div>
                            <div class="clear"></div>
                        </div>
                    </dd>
                    </c:forEach>
                </dl>
            </div>
            <div class="clear"></div>
            <div class="keeptemp">
                <ul>
                    <li><a href="javascript:;" class="keeptempupdate">保存并返回</a></li>
                    <li><a href="javascript:;" class="canceltempsetup">取消</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!-- 运输管理通用尾部 -->
<script src="/static/js/jquery-1.10.2.min.js"></script>
<script src="/static/js/common.js"></script>
<jsp:include page="../common/footer.jsp" flush="true"></jsp:include>
<!-- 运输管理通用尾部 end -->
<div class="overbg"></div>
<script src="/static/js/newfreighttemp.js"></script>
<script type="application/javascript">
    $(function(){
        if($('.settemptype i').eq(1).hasClass('selected')){
            $('.tempname').eq(2).hide();
        }
    });
</script>
</body>
</html>